***************************************************************************************
***************************************************************************************
** Stata Code for Analyzing Data from AMOS 2014
** PROJECT: Revenue Source and Electoral Accountability: Experimental Evidence from Local U.S. Policymakers
** AUTHORS: Adam Dynes and Lucy Martin
** DATE: January 18, 2017
***************************************************************************************
***************************************************************************************

      

clear all


use "dynes-martin_replication_AMOS2014.dta", clear



************************************************************************************************
// ANALYZE THE MINOR SCANDAL QUESTIONS (FIGURE 2)
************************************************************************************************

	
**Table  A-15:Regression  Results  for  Figure  2
**Table  A-16:Regression  Results  for  Figure  A-9.

	foreach x of varlist tx_mediacover tx_citizensnotice tx_runsagainst tx_willlose {
		
		reg `x'_n  i.treat1
			estimate store `x'_n
		**TABLE A-15 (`x'_d)
			reg `x'_d  i.treat1
				estimate store `x'_d
		reg `x'_7  i.treat1
			estimate store `x'_7
		**TABLE A-16 (`x'_0)
			reg `x'_0  i.treat1
				estimate store `x'_7
		}
		

**Figure 2:Effect of revenue source on local policymakers’ perceptions of the consequences ofa  minor  scandal  (AMOS  2014).

	coefplot tx_mediacover_d ||  ///
	tx_citizensnotice_d ||  ///
	tx_runsagainst_d || ///
	tx_willlose_d || ///
	, ///
	drop(_cons) omitted  yline(0) vertical ///
	ylabel(-.1(.1).2) grid(-.1(.1).2) mcolor(black) msize(medium) ciopts(lcolor(black) lwidth(medthick)) xlabel(,angle(45))   ///
	  base ytitle("Difference (Impact of funding source" "on likelihood of outcome)") ///
	graphregion(color(white) fcolor(white)) plotregion(color(white))  ///
	scheme(s2mono)
	graph save "AD_dum.gph", replace
	**SAVE MANUALLY** I can't figure out how to label the title above each coefficient plot so that it's not just the name of the dependent variable in each regression. I have I have to change each one manually, which is why I don't automatically export the figure to a pdf.
	**graph export "AD_dum.pdf", as(pdf) replace

**Figure A-9:Figure 2 with 7-point Outcome.
	coefplot (tx_mediacover_n) || tx_citizensnotice_n  || ///
	tx_runsagainst_n || tx_willlose_n, ///
	drop(_cons) omitted  yline(0) vertical ///
	ylabel(-.1(.1).6, nogrid) mcolor(black) msize(small) ciopts(lcolor(black) lwidth(thin)) xlabel(,angle(45))   ///
	graphregion(color(white) fcolor(white)) plotregion(color(white))  base ytitle("Difference (Impact of funding source" "on likelihood of outcome)") scheme(s2mono)
	graph save "AD_num.gph", replace
	graph export "AD_num.pdf", as(pdf) replace

			
**Table  A-17:Descriptive  Statistics  of  Variables  Used  in  Robustness  Checks  ofAnalysis from Figure 2.
	preserve
		keep if tx_mediacover<. | tx_citizensnotice<. | tx_runsagainst<. | tx_willlose<. 
		
		gen insample=0
		
		foreach x in tx_mediacover tx_citizensnotice tx_runsagainst tx_willlose {
			qui reg `x'_d female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool
			replace insample=1 if e(sample)
		}
		
		keep if insample==1
		
		sum female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool, detail
		
		// List Variable Labels
		foreach var in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
			di "`var'" _col(30) "`: var l `var''" _col(50)  "`: val l `var''"
		}
			
		foreach var in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
			di "`: var l `var''" _col(50)  "`: val l `var''"
			}

			
		
		estpost summarize female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool, detail
		

		esttab, cells("mean sd p50 count min max") label
	restore


**FIGURE 2 with controls and treatment*covariate interactions

	local controls female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool    			

	local outoptions label tex(frag) word se bdec(3) sdec(3) symbol(*,*)
	
	xtset state_fips

	**Table A-18:Regression Results for Figure 2 with Control Variables.
		xtreg tx_mediacover_d i.treat1 `controls'
			outreg2 using Figure2_OLSdum_controls, replace `outoptions'
		
		foreach x in tx_citizensnotice tx_runsagainst tx_willlose {
			xtreg `x'_d i.treat1 `controls'
			outreg2 using Figure2_OLSdum_controls, append `outoptions'		
			}
		
	**Table A-19:Regression Results for Figure 2 with Control Variables and 7-pointOutcome.
		xtreg tx_mediacover_0 i.treat1 `controls'
			outreg2 using Figure2_OLS7_controls, replace `outoptions'
		
		foreach x in tx_citizensnotice tx_runsagainst tx_willlose {
			xtreg `x'_0 i.treat1 `controls'
			outreg2 using Figure2_OLS7_controls, append `outoptions'		
			}



**Table  A-30:Testing  for  Heterogeneous  Treatment  Effects  from  Figure  2  withIndividual-Level  Variables.
	xtset state_fips
	
	foreach var in female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
		gen tX`var' = saw_tax*`var'
		gen mX`var' = saw_mix*`var'
	}


	xtreg tx_mediacover_d saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican  `controls'
	regsave saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican using subgroup_interactions_fig2.dta, ci pval  addlabel(table, 2, interaction, party, outcome, mediacover) replace

	reg tx_mediacover_d saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican
	regsave saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican using subgroup_interactions_fig2_nocontrols.dta, ci pval  addlabel(table, 2, interaction, party, outcome, mediacover) replace

	foreach y in citizensnotice runsagainst willlose {
		xtreg tx_`y'_d saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican `controls'			
		regsave saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican using subgroup_interactions_fig2.dta, ci pval  addlabel(table, 2, interaction, party, outcome, `y') append
		
		reg tx_`y'_d saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican
		regsave saw_tax saw_mix independent republican tXindependent tXrepublican mXindependent mXrepublican using subgroup_interactions_fig2_nocontrols.dta, ci pval  addlabel(table, 2, interaction, party, outcome, `y') append
	}


	foreach x in female ideology mayor served4 close challenger stayinoffice runforhigher atlarge multimember bachelors gradschool    {
		foreach y in mediacover citizensnotice runsagainst willlose {
			xtreg tx_`y'_d saw_tax saw_mix `x' tX`x' mX`x' `controls'
			regsave saw_tax saw_mix `x' tX`x' mX`x' using subgroup_interactions_fig2.dta, ci pval  addlabel(table, 2, interaction, `x', outcome, `y') append
			reg tx_`y'_d saw_tax saw_mix `x' tX`x' mX`x'	
			regsave saw_tax saw_mix `x' tX`x' mX`x' using subgroup_interactions_fig2_nocontrols.dta, ci pval  addlabel(table, 2, interaction, `x', outcome, `y') append
		}
	}

	foreach name in fig2 fig2_nocontrols {
	preserve
		clear
		use "subgroup_interactions_`name'.dta"
		gen treat=0
		replace treat=1 if regexm(var, "tX")
		replace treat=2 if regexm(var, "mX")
		keep if treat==1 | treat==2
		keep var coef stderr pval outcome treat
		replace outcome=outcome+"_tX" if treat==1
		replace outcome=outcome+"_mX" if treat==2
		replace var=subinstr(var,"mX","",1)
		replace var=subinstr(var,"tX","",1)			
		replace coef = round(coef,.001)
		replace stderr = round(stderr,.001)
		replace pval = round(pval,.001)
		sort var
		gen order1=.
		replace order1=1 if outcome=="mediacover_tX"
		replace order1=3 if outcome=="citizensnotice_tX"
		replace order1=5 if outcome=="runsagainst_tX"
		replace order1=7 if outcome=="willlose_tX"
		replace order1=2 if outcome=="mediacover_mX"
		replace order1=4 if outcome=="citizensnotice_mX"
		replace order1=6 if outcome=="runsagainst_mX"
		replace order1=8 if outcome=="willlose_mX"

		sort var order1

		rename coef est_coef
		rename stderr est_stderr
		reshape long est_, i(var outcome order pval) j(type) string
		rename est_ estimate
		gen order2=.
		replace order2=1 if type=="coef"
		replace order2=2 if type=="stderr"
		sort var order1 order2
		drop outcome type treat
		order estimate, before(pval)
		reshape wide estimate pval, i(var order2) j(order1)
		

		rename estimate1 mediacover_tX
		rename estimate3 citizensnotice_tX
		rename estimate5 runsagainst_tX
		rename estimate7 willlose_tX
		rename estimate2 mediacover_mX
		rename estimate4 citizensnotice_mX
		rename estimate6 runsagainst_mX
		rename estimate8 willlose_mX
		
		foreach num of numlist 1/8 {
			replace pval`num'=. if order2==1
		}
		
		rename pval1 mediacover_tXp
		rename pval3 citizensnotice_tXp
		rename pval5 runsagainst_tXp
		rename pval7 willlose_tXp
		rename pval2 mediacover_mXp
		rename pval4 citizensnotice_mXp
		rename pval6 runsagainst_mXp
		rename pval8 willlose_mXp

		order order2, first
		gen order1=.
					
		replace order1=1 if var=="female"
		replace order1=2 if var=="republican"
		replace order1=3 if var=="independent"
		replace order1=5 if var=="ideology"
		replace order1=6 if var=="mayor"
		replace order1=7 if var=="commissioner"
		replace order1=9 if var=="served4"
		replace order1=10 if var=="close"
		replace order1=11 if var=="challenger"
		replace order1=12 if var=="unelected"
		replace order1=13 if var=="stayinoffice"
		replace order1=14 if var=="runforhigher"
		replace order1=15 if var=="atlarge"
		replace order1=16 if var=="multimember"
		replace order1=17 if var=="lesscollege"
		replace order1=18 if var=="bachelors"
		replace order1=19 if var=="gradschool"


		
		order order1, first
		sort order1 order2
		replace var="Female (1=yes)" if var=="female"
		replace var="Republican (1=yes)" if var=="republican"
		replace var="Independent (1=yes)" if var=="independent"
		replace var="Democrat (1=yes)" if var=="democrat"
		replace var="Self-Placed Ideology (7-pt., 1=Very Liberal)" if var=="ideology"
		replace var="Mayor (1=yes)" if var=="mayor"
		replace var="Commissioner (1=yes)" if var=="commissioner"
		replace var="Councilor (1=yes)" if var=="councilor"
		replace var="Has served 4 yrs. or less in elected office (1=yes)" if var=="served4"
		replace var="Won last election by less than 10% pts. (1=yes)" if var=="close"
		replace var="Faced challenger in primary or general (1=yes)" if var=="challenger"
		replace var="Unelected Official (1=yes)" if var=="unelected"
		replace var="Wants to hold munic. office in 5 yrs. (1=yes)" if var=="stayinoffice"
		replace var="Wants to hold higher office in 5 yrs. (1=yes)" if var=="runforhigher"
		replace var="Holds at-large seat (1=yes)" if var=="atlarge"
		replace var="In multi-member district (1=yes)" if var=="multimember"
		replace var="Has less than bachelor's degree (1=yes)" if var=="lesscollege"
		replace var="Has bachelor's degree (1=yes)" if var=="bachelors"
		replace var="Has graduate degree (1=yes)" if var=="gradschool"

		
		compress
		save "subgroup_interactions_`name'_clean.dta", replace
	restore
	}



************************************************************************************************
** TOP-DOWN MONITORING OF GRANTS (TABLE 3)
************************************************************************************************



**Table 3:Beliefs  about  top-down  monitoring  of  outside  grants  (AMOS  2014).
	foreach num of numlist 1/7 {
		local lab: variable label grant_agds_`num'
		display "`lab'"
		sum grant_agds_`num'_n
		sum grant_agds_`num'_d
	}
	

**Figure A-10:Distribution of responses from Table 3.
	histogram grant_agds_1_n, discrete percent  name(g_1, replace) nodraw xtitle(Grantors understand cits' priorities) scheme(s2mono)
	histogram grant_agds_2_n, discrete percent  name(g_2, replace) nodraw xtitle(Grantors care about Cits' priorities) scheme(s2mono)
	histogram grant_agds_3_n, discrete percent  name(g_3, replace) nodraw xtitle(Must report all budget chgs to grantors) scheme(s2mono)
	histogram grant_agds_4_n, discrete percent  name(g_4, replace) nodraw xtitle(Grantors heavily monitor spending) scheme(s2mono)
	histogram grant_agds_5_n, discrete percent  name(g_5, replace) nodraw xtitle(Grantors notice how money spent) scheme(s2mono)
	histogram grant_agds_6_n, discrete percent  name(g_6, replace) nodraw xtitle(Misuse reduces Pr(get same grant)) scheme(s2mono)
	histogram grant_agds_7_n, discrete percent  name(g_7, replace) nodraw xtitle(Misuse reduces Pr(get other grants)) scheme(s2mono)
	graph combine g_1 g_2 g_3 g_4 g_5 g_6 g_7, cols(3) ycommon scheme(s2mono)
		graph export "grant_histo.pdf", replace as(pdf)



		
**Table  A-20:Descriptive  Statistics  of  Variables  Used  in  Robustness  Checks  ofAnalysis  from  Table  3.
	preserve
		gen insample=0
		
		foreach num of numlist 1/7 {
			qui reg grant_agds_`num'_n female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool
			replace insample=1 if e(sample)
		}
		
		keep if insample==1
		
		// List Variable Labels
		foreach var in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
			di "`var'" _col(30) "`: var l `var''" _col(50)  "`: val l `var''"
		}
			
		foreach var in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
			di "`: var l `var''" _col(50)  "`: val l `var''"
			}

			
		
		estpost summarize female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool, detail
		

		esttab, cells("mean sd p50 count min max") label
	restore
	
	
		
**Table A-21:OLS Regression Analysis of Table 3.
	local outoptions label tex(frag) word se bdec(2) sdec(2) symbol(*,*)
	

	reg grant_agds_1_d  female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember bachelors gradschool    
	outreg2 using Table3_controls_`x', replace `outoptions'

	foreach num of numlist 2/7 {
		reg grant_agds_`num'_d female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember bachelors gradschool    
		outreg2 using Table3_controls_`x', append `outoptions'
	}
	
	
**Table A-22:OLS Regression Analysis of Table 3 with 6-point Outcome.

	reg grant_agds_1_n  female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember bachelors gradschool    
	outreg2 using Table3_controls_`x', replace `outoptions'

	foreach num of numlist 2/7 {
		reg grant_agds_`num'_n female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember bachelors gradschool    
		outreg2 using Table3_controls_`x', append `outoptions'
	
	}

**Table A-23:Regression Analysis of Table 3 using Logit.
				
	logit grant_agds_1_d  female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember bachelors gradschool     
	outreg2 using Table3_controls_logit, replace `outoptions'

	foreach num of numlist 2/7 {
		logit grant_agds_`num'_d female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember bachelors gradschool     
		outreg2 using Table3_controls_logit, append `outoptions'
	
	}




************************************************************************************************
// PAIRWISE COMPARISON ANALYSIS (FIGURE 1)
************************************************************************************************


		
// Reshape long for MISCOR & MISREP variables.
	reshape long cor_choice_a cor_grant_w_match_a cor_grant_no_match_a cor_tax_a cor_pork_a ///
		cor_choice_b cor_grant_w_match_b cor_grant_no_match_b cor_tax_b cor_pork_b ///
		rep_choice_a rep_grant_w_match_a rep_grant_no_match_a rep_tax_a rep_pork_a ///
		rep_choice_b rep_grant_w_match_b rep_grant_no_match_b rep_tax_b rep_pork_b, i(id) j(profile)

// Make new unique ID
	gen pid=_n
	
// Make numeric suffixes
		rename rep_choice_a rep_chosen1
		rename cor_choice_a cor_chosen1
		rename rep_choice_b rep_chosen2
		rename cor_choice_b cor_chosen2
		local stems "cor_grant_w_match cor_grant_no_match cor_tax cor_pork rep_grant_w_match rep_grant_no_match rep_tax rep_pork"
		foreach x of local stems {
			rename `x'_a `x'1
			rename `x'_b `x'2
			}
		
		compress

	
// INITIAL ANALYSIS: BY COMBOS - CORRUPTION OUTCOMES
	
	* Tax vs. Pork
	gen taxpork=cond((cor_pork1==1 | cor_pork2==1) & (cor_tax1==1 | cor_tax2==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen tax_pork=cond((cor_pork2==1) & (cor_tax1==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen pork_tax=cond((cor_pork1==1) & (cor_tax2==1),1,0) if cor_chosen1==1 | cor_chosen2==1

		gen pork_overtax=cond((tax_pork==1 & cor_chosen1==0) | (pork_tax==1 & cor_chosen1==1),1,0) if taxpork==1
		gen tax_overpork=1-pork_overtax if pork_overtax!=.
		
	* Tax vs. Grant With Matching Funds			
	gen taxgrantwm=cond((cor_grant_w_match1==1 | cor_grant_w_match 2==1) & (cor_tax1==1 | cor_tax2==1),1,0) if cor_chosen1==1 | cor_chosen2==1	
		gen tax_grantwm= cond((cor_grant_w_match2==1) & (cor_tax1==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen grantwm_tax= cond((cor_grant_w_match1==1) & (cor_tax2==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		
		gen grantwm_overtax=cond((tax_grantwm==1 & cor_chosen1==0) | (grantwm_tax==1 & cor_chosen1==1),1,0) if taxgrantwm==1
		gen tax_overgrantwm=1-grantwm_overtax if grantwm_overtax!=.
		
	* Tax vs. Grant Without Matching Funds		
	gen taxgrantnom=cond((cor_grant_no_match1==1 | cor_grant_no_match 2==1) & (cor_tax1==1 | cor_tax2==1),1,0) if cor_chosen1==1 | cor_chosen2==1	
		gen tax_grantnom= cond((cor_grant_no_match2==1) & (cor_tax1==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen grantnom_tax= cond((cor_grant_no_match1==1) & (cor_tax2==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		
		gen grantnom_overtax=cond((tax_grantnom==1 & cor_chosen1==0) | (grantnom_tax==1 & cor_chosen1==1),1,0) if taxgrantnom==1
		gen tax_overgrantnom=1-	grantnom_overtax if grantnom_overtax!=.
			
	* Pork vs. Grant without Matching Funds (NOTE: SUGGESTS pork not as bad as pure outside funds?? CHECK CODING)
	gen porkgrantnom=cond((cor_grant_no_match1==1 | cor_grant_no_match2==1) & (cor_pork1==1 | cor_pork2==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen pork_grantnom=cond((cor_grant_no_match2==1) & (cor_pork1==1),1,0) if cor_chosen1==1 | cor_chosen2==1 			
		gen grantnom_pork=cond((cor_grant_no_match1==1) & (cor_pork2==1),1,0) if cor_chosen1==1 | cor_chosen2==1 			 
				 		
		gen pork_overgrantnom=cond((pork_grantnom==1 & cor_chosen1==1 ) | (grantnom_pork==1 & cor_chosen1==0),1,0) if porkgrantnom==1
		gen grantnom_overpork=1-pork_overgrantnom if pork_overgrantnom!=.
		
	* Pork vs. Grant with Matching Funds
	gen porkgrantwm=cond((cor_grant_w_match1==1 | cor_grant_w_match2==1) & (cor_pork1==1 | cor_pork2==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen pork_grantwm=cond((cor_grant_w_match2==1) & (cor_pork1==1),1,0) if cor_chosen1==1 | cor_chosen2==1 			
		gen grantwm_pork=cond((cor_grant_w_match1==1) & (cor_pork2==1),1,0) if cor_chosen1==1 | cor_chosen2==1 			 
				 		
		gen pork_overgrantwm=cond((pork_grantwm==1 & cor_chosen1==1 ) | (grantwm_pork==1 & cor_chosen1==0),1,0)  if porkgrantwm==1 			 
		gen grantwm_overpork=1-pork_overgrantwm if pork_overgrantwm!=.
		
	* Grant With Matching vs. Grant Without Matching
	gen grantwmgrantnom=cond((cor_grant_w_match1==1 | cor_grant_w_match2==1) & (cor_grant_no_match1==1 | cor_grant_no_match2==1),1,0) if cor_chosen1==1 | cor_chosen2==1
		gen grantnom_grantwm=cond((cor_grant_w_match2==1) & (cor_grant_no_match1 ==1),1,0) if cor_chosen1==1 | cor_chosen2==1 			
		gen grantwm_grantnom=cond((cor_grant_w_match1==1) & (cor_grant_no_match2 ==1),1,0) if cor_chosen1==1 | cor_chosen2==1 			 
				 		
		gen grantnom_overgrantwm=cond((grantnom_grantwm ==1 & cor_chosen1==1 ) | (grantwm_grantnom ==1 & cor_chosen1==0),1,0)  if grantwmgrantnom ==1 			 
		gen grantwm_overgrantnom=1-grantnom_overgrantwm if grantnom_overgrantwm!=.


// INITIAL ANALYSIS: BY COMBOS - REPRESENTATION OUTCOMES

	* Tax vs. Pork
	gen taxpork_r=cond((rep_pork1==1 | rep_pork2==1) & (rep_tax1==1 | rep_tax2==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen tax_pork_r=cond((rep_pork2==1) & (rep_tax1==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen pork_tax_r=cond((rep_pork1==1) & (rep_tax2==1),1,0) if rep_chosen1==1 | rep_chosen2==1

		gen pork_overtax_r=cond((tax_pork_r==1 & rep_chosen1==0) | (pork_tax_r==1 & rep_chosen1==1),1,0) if taxpork_r==1

	* Tax vs. Grant With Matching Funds			
	gen taxgrantwm_r=cond((rep_grant_w_match1==1 | rep_grant_w_match 2==1) & (rep_tax1==1 | rep_tax2==1),1,0) if rep_chosen1==1 | rep_chosen2==1	
		gen tax_grantwm_r= cond((rep_grant_w_match2==1) & (rep_tax1==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen grantwm_tax_r= cond((rep_grant_w_match1==1) & (rep_tax2==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		
		gen grantwm_overtax_r=cond((tax_grantwm_r==1 & rep_chosen1==0) | (grantwm_tax_r==1 & rep_chosen1==1),1,0) if taxgrantwm_r==1
		
	* Tax vs. Grant Without Matching Funds		
	gen taxgrantnom_r=cond((rep_grant_no_match1==1 | rep_grant_no_match 2==1) & (rep_tax1==1 | rep_tax2==1),1,0) if rep_chosen1==1 | rep_chosen2==1	
		gen tax_grantnom_r= cond((rep_grant_no_match2==1) & (rep_tax1==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen grantnom_tax_r= cond((rep_grant_no_match1==1) & (rep_tax2==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		
		gen grantnom_overtax_r=cond((tax_grantnom_r==1 & rep_chosen1==0) | (grantnom_tax_r==1 & rep_chosen1==1),1,0) if taxgrantnom_r==1
		 	
	* Pork vs. Grant without Matching Funds 
	gen porkgrantnom_r=cond((rep_grant_no_match1==1 | rep_grant_no_match2==1) & (rep_pork1==1 | rep_pork2==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen pork_grantnom_r=cond((rep_grant_no_match2==1) & (rep_pork1==1),1,0) if rep_chosen1==1 | rep_chosen2==1 			
		gen grantnom_pork_r=cond((rep_grant_no_match1==1) & (rep_pork2==1),1,0) if rep_chosen1==1 | rep_chosen2==1 			 
				 		
		gen pork_overgrantnom_r=cond((pork_grantnom_r==1 & rep_chosen1==1 ) | (grantnom_pork_r==1 & rep_chosen1==0),1,0) if porkgrantnom_r==1

	* Pork vs. Grant with Matching Funds
	gen porkgrantwm_r=cond((rep_grant_w_match1==1 | rep_grant_w_match2==1) & (rep_pork1==1 | rep_pork2==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen pork_grantwm_r=cond((rep_grant_w_match2==1) & (rep_pork1==1),1,0) if rep_chosen1==1 | rep_chosen2==1 			
		gen grantwm_pork_r=cond((rep_grant_w_match1==1) & (rep_pork2==1),1,0) if rep_chosen1==1 | rep_chosen2==1 			 
				 		
		gen pork_overgrantwm_r=cond((pork_grantwm_r==1 & rep_chosen1==1 ) | (grantwm_pork_r==1 & rep_chosen1==0),1,0)  if porkgrantwm_r==1 			 
		
	* Grant With Matching vs. Grant Without Matching
	gen grantwmgrantnom_r=cond((rep_grant_w_match1==1 | rep_grant_w_match2==1) & (rep_grant_no_match1==1 | rep_grant_no_match2==1),1,0) if rep_chosen1==1 | rep_chosen2==1
		gen grantnom_grantwm_r=cond((rep_grant_w_match2==1) & (rep_grant_no_match1 ==1),1,0) if rep_chosen1==1 | rep_chosen2==1 			
		gen grantwm_grantnom_r=cond((rep_grant_w_match1==1) & (rep_grant_no_match2 ==1),1,0) if rep_chosen1==1 | rep_chosen2==1 			 
				 		
		gen grantnom_overgrantwm_r=cond((grantnom_grantwm_r ==1 & rep_chosen1==1 ) | (grantwm_grantnom_r ==1 & rep_chosen1==0),1,0)  if grantwmgrantnom_r ==1 			 


	gen pairing=""
	foreach x of varlist taxpork taxgrantwm taxgrantnom porkgrantnom porkgrantwm grantwmgrantnom {
		replace pairing="`x'" if `x'==1
		replace pairing="`x'" if `x'_r==1
	}

		

// Reshape into full dataset: 8 observations per individual
	reshape long cor_chosen cor_grant_w_match cor_grant_no_match cor_tax cor_pork rep_chosen rep_grant_w_match rep_grant_no_match rep_tax rep_pork, i(pid) j(profileab)

	// Gen measure for coefplot
	gen cor_funst=""
	replace cor_funst="3Pork" if cor_pork==1 
	replace cor_funst="4Grant" if cor_grant_no_match==1
	replace cor_funst="2Mix of Tax & Grant" if cor_grant_w_match==1
	replace cor_funst="1Local Tax" if cor_tax==1
	encode cor_funst, gen(cor_funding)
	
	gen rep_funst=""
	replace rep_funst="3Pork" if rep_pork==1 
	replace rep_funst="4Grant" if rep_grant_no_match==1
	replace rep_funst="2Mix of Tax & Grant" if rep_grant_w_match==1
	replace rep_funst="1Local Tax" if rep_tax==1
	encode rep_funst, gen(rep_funding)
		
// Gen Treatment and Interactions for Robustness check

	gen conjoint_tax = 0 if rep_funding<. | cor_funding<.
	replace conjoint_tax = 1 if rep_funding==1 | cor_funding==1
	gen conjoint_mix = 0 if rep_funding<. | cor_funding<.
	replace conjoint_mix = 1 if rep_funding==2 | cor_funding==2
	gen conjoint_pork = 0 if rep_funding<. | cor_funding<.
	replace conjoint_pork = 1 if rep_funding==3 | cor_funding==3
	gen conjoint_grant = 0 if rep_funding<. | cor_funding<.
	replace conjoint_grant = 1 if rep_funding==4 | cor_funding==4

	foreach x in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool      {
		gen ctX`x' = conjoint_tax*`x'
		gen cmX`x' = conjoint_mix*`x'
		gen cpX`x' = conjoint_pork*`x'
		gen cgX`x' = conjoint_grant*`x'
	}
	


**Figure A-7:Revenue pair results from Figure 1.	
	graph drop _all
	graph hbar (mean) cor_chosen, over(cor_funding) over(pairing, reverse label(nolabels)) nofill name(hbar_cor) ytitle("Misuse More Likely, N=10,120")	graphregion(color(white))  

	graph hbar (mean) rep_chosen, over(rep_funding) over(pairing, reverse label(nolabels)) nofill  name(hbar_rep) ytitle("Policy Incongruence More Likely, N=10,768")	graphregion(color(white))  

	graph combine hbar_cor hbar_rep, xcommon xsize(6) graphregion(color(white))
		graph export "pairings.pdf", as(pdf)  replace    

		
**Table A-5:Regression results for Figure 1.	

	reg cor_chosen ib4.cor_funding, cluster(id)
		estimates store cor_chosen
	
	reg rep_chosen ib4.rep_funding, cluster(id)
		estimates store rep_chosen

		
**Figure 1: Regression  results:  local  policymakers’  beliefs  about  revenue  types,  policy  incon-gruence, and misuse (AMOS 2014).		
	graph drop _all
	coefplot cor_chosen, drop(_cons) xline(0) omitted base name(cor) xtitle("Pr(Misuse), N=10,120") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  
	coefplot rep_chosen, drop(_cons) xline(0) omitted base name(rep) xtitle("Pr(Policy Incongruence), N=10,768") nodraw graphregion(color(white)) plotregion(lcolor(black) lwidth(med))
	graph combine rep cor, xcommon xsize(6) graphregion(color(white)) name(correp)
		
	graph save "cor_rep", replace
		*SAVE MANUALLYgraph export "cor_rep.pdf", as(pdf)  replace   


**Table A-6:Regression results for Figure 1 limited to the first pairwise comparisonviewed by each respondent.			
	reg cor_chosen ib4.cor_funding if profile==1, cluster(id)
		estimates store cor_chosen1
	
	reg rep_chosen ib4.rep_funding if profile==1, cluster(id)
		estimates store rep_chosen1


**Figure A-8:Figure 1 limited to the first pairwise comparison viewed by each re-spondent.		
	coefplot cor_chosen1, drop(_cons) xline(0) omitted base name(cor1) xtitle("Pr(Misuse), N=2,530") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  
	coefplot rep_chosen1, drop(_cons) xline(0) omitted base name(rep1) xtitle("Pr(Policy Incongruence), N=2,692") nodraw graphregion(color(white)) plotregion(lcolor(black) lwidth(med))
	graph combine rep1 cor1, xcommon xsize(6) graphregion(color(white)) name(correp1st)
		
	graph save "cor_rep_1stresponse", replace
		*SAVE MANUALLYgraph export "cor_rep_1stresponse.pdf", as(pdf)  replace  
			

**Table A-7:Regression results for Figure 1 and Table A-5 with respondent-levelfixed effects.
		xtset id
		
		xtreg rep_chosen ib4.rep_funding, vce(cluster id)
			outreg2 using fig1_ind-FE, replace `outoptions'	
	
		xtreg cor_chosen ib4.cor_funding, vce(cluster id)
			outreg2 using fig1_ind-FE, append `outoptions'
		

**Table A-9:Tables A-5 and A-6 with control variables.
	**with controls 
		local outoptions label tex(frag) word se bdec(2) sdec(2) symbol(*,*)
				
		local controls female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool    			
				
				reg rep_chosen ib4.rep_funding `controls' i.state_fips, vce(cluster id)
					outreg2 using fig1_controls, replace `outoptions'	
			
				reg cor_chosen ib4.cor_funding `controls' i.state_fips, vce(cluster id)
					outreg2 using fig1_controls, append `outoptions'
			
	**first response only
		reg rep_chosen ib4.rep_funding `controls' i.state_fips if profile==1, vce(cluster id)
				outreg2 using fig1_controls, append `outoptions'	

		reg cor_chosen ib4.cor_funding `controls' i.state_fips if profile==1, vce(cluster id)
				outreg2 using fig1_controls, append `outoptions'



**Figure A-11:Figure 1 by Gender.

	reg rep_chosen ib4.rep_funding `controls' i.state_fips if female==1, vce(cluster id)		
		estimates store rep_chosen_fem
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if female==1, vce(cluster id)		
		estimates store cor_chosen_fem
		
	coefplot rep_chosen_fem, keep(*.rep_funding) xline(0) omitted base name(rep_fem, replace) xtitle("Pr(Policy Incongruence)") title("Women") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_fem, keep(*.cor_funding) xline(0) omitted base name(cor_fem, replace) title("Women") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 
	
	reg rep_chosen ib4.rep_funding `controls' i.state_fips if female==0, vce(cluster id)		
		estimates store rep_chosen_mal
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if female==0, vce(cluster id)		
		estimates store cor_chosen_mal
		
	coefplot rep_chosen_mal, keep(*.rep_funding) xline(0) omitted base name(rep_mal, replace) xtitle("Pr(Policy Incongruence)") title("Men") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_mal, keep(*.cor_funding) xline(0) omitted base name(cor_mal, replace) title("Men") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 

				
	graph combine rep_fem cor_fem rep_mal cor_mal, cols(2) xcommon iscale(.5) graphregion(color(white)) name(correp_gender, replace)

	graph export "cor_rep_gender.pdf", as(pdf)  replace 


**Figure A-12:Figure 1 by Party.
	reg rep_chosen ib4.rep_funding `controls' i.state_fips if republican==1, vce(cluster id)		
		estimates store rep_chosen_rep
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if republican==1, vce(cluster id)		
		estimates store cor_chosen_rep
		
	coefplot rep_chosen_rep, keep(*.rep_funding) xline(0) omitted base name(rep_rep, replace) xtitle("Pr(Policy Incongruence)") title("Republicans") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_rep, keep(*.cor_funding) xline(0) omitted base name(cor_rep, replace) title("Republicans") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 
	
	reg rep_chosen ib4.rep_funding `controls' i.state_fips if independent==1, vce(cluster id)		
		estimates store rep_chosen_ind
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if independent==1, vce(cluster id)		
		estimates store cor_chosen_ind
		
	coefplot rep_chosen_ind, keep(*.rep_funding) xline(0) omitted base name(rep_ind, replace) xtitle("Pr(Policy Incongruence)") title("Independents") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_ind, keep(*.cor_funding) xline(0) omitted base name(cor_ind, replace) title("Independents") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 

	reg rep_chosen ib4.rep_funding `controls' i.state_fips if democrat==1, vce(cluster id)		
		estimates store rep_chosen_dem
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if democrat==1, vce(cluster id)		
		estimates store cor_chosen_dem			

	coefplot rep_chosen_dem, keep(*.rep_funding) xline(0) omitted base name(rep_dem, replace) xtitle("Pr(Policy Incongruence)") title("Democrats") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_dem, keep(*.cor_funding) xline(0) omitted base name(cor_dem, replace) title("Democrats") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 		
	
	graph combine rep_rep cor_rep rep_ind cor_ind rep_dem cor_dem, cols(2) xcommon iscale(.5) graphregion(color(white)) name(correp_party, replace)

	graph export "cor_rep_party.pdf", as(pdf)  replace  
		
	
**Figure A-13:Figure 1 by Ideology.
	reg rep_chosen ib4.rep_funding `controls' i.state_fips if ideology>=5 & ideology<=7, vce(cluster id)		
		estimates store rep_chosen_con
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if ideology>=5 & ideology<=7, vce(cluster id)		
		estimates store cor_chosen_con
		
	coefplot rep_chosen_con, keep(*.rep_funding) xline(0) omitted base name(rep_con, replace) xtitle("Pr(Policy Incongruence)") title("Conservatives") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_con, keep(*.cor_funding) xline(0) omitted base name(cor_con, replace) title("Conservatives") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 
	
	reg rep_chosen ib4.rep_funding `controls' i.state_fips if ideology==4, vce(cluster id)		
		estimates store rep_chosen_mod
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if ideology==4, vce(cluster id)		
		estimates store cor_chosen_mod
		
	coefplot rep_chosen_mod, keep(*.rep_funding) xline(0) omitted base name(rep_mod, replace) xtitle("Pr(Policy Incongruence)") title("Moderates") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_mod, keep(*.cor_funding) xline(0) omitted base name(cor_mod, replace) title("Moderates") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 

	reg rep_chosen ib4.rep_funding `controls' i.state_fips if ideology>=1 & ideology<=3, vce(cluster id)		
		estimates store rep_chosen_lib
		
	reg cor_chosen ib4.cor_funding `controls' i.state_fips if ideology>=1 & ideology<=3, vce(cluster id)		
		estimates store cor_chosen_lib			

	coefplot rep_chosen_lib, keep(*.rep_funding) xline(0) omitted base name(rep_lib, replace) xtitle("Pr(Policy Incongruence)") title("Liberals") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white))  

	coefplot cor_chosen_lib, keep(*.cor_funding) xline(0) omitted base name(cor_lib, replace) title("Liberals") xtitle("Pr(Misuse)") nodraw plotregion(lcolor(black) lwidth(med)) graphregion(color(white)) 		
	
	graph combine rep_con cor_con rep_mod cor_mod rep_lib cor_lib, cols(2) xcommon iscale(.5) graphregion(color(white)) name(correp_ideo, replace)

	graph export "cor_rep_ideo.pdf", as(pdf)  replace  
		

				
**Table A-8:Descriptive Statistics of Variables Used in Robustness Checks of Anal-ysis from Figure 1.
	preserve
		keep if rep_chosen<. | cor_chosen<. 
		
		sort rep_chosen cor_chosen
		duplicates drop id, force
		
		gen insample=0
		
		foreach x in rep_chosen cor_chosen {
			qui reg `x' female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool
			replace insample=1 if e(sample)
		}
		
		keep if insample==1
		
		sum female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool, detail
		
		// List Variable Labels
		foreach var in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
			di "`var'" _col(30) "`: var l `var''" _col(50)  "`: val l `var''"
		}
			
		foreach var in female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool {
			di "`: var l `var''" _col(50)  "`: val l `var''"
			}

			
		
		estpost summarize female republican independent democrat ideology mayor commissioner councilor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool, detail
		

		esttab, cells("mean sd p50 count min max") label
	restore
	
	
	
**Table  A-27:Testing  for  Heterogeneous  Treatment  Effects  from  Figure  1  withMunicipal-Level  Variables.
	xtset id
	local controls female republican independent ideology mayor served4 close challenger unelected stayinoffice runforhigher atlarge multimember lesscollege bachelors gradschool    
	
	
	xtreg rep_chosen conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican  `controls', cluster(id)
	regsave conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican using subgroup_interactions_fig1.dta, ci pval addlabel(figure, 1, interaction, party, outcome, rep_chosen) replace
	
	reg rep_chosen conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican, cluster(id)
	regsave conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican using subgroup_interactions_fig1_nocontrols.dta, ci pval addlabel(figure, 1, interaction, party, outcome, rep_chosen) replace


		xtreg cor_chosen conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican  `controls', cluster(id)	
		regsave conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican using subgroup_interactions_fig1.dta, ci pval  addlabel(figure, 1, interaction, party, outcome, cor_chosen) append
		
		reg cor_chosen conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican, cluster(id)
		regsave conjoint_tax conjoint_mix conjoint_pork independent republican ctXindependent ctXrepublican cmXindependent cmXrepublican cpXindependent cpXrepublican using subgroup_interactions_fig1_nocontrols.dta, ci pval  addlabel(figure, 1, interaction, party, outcome, cor_chosen) append


	
	foreach x in female ideology mayor served4 close challenger stayinoffice runforhigher atlarge multimember bachelors gradschool    {
		foreach y in rep_chosen cor_chosen {
			xtreg `y' conjoint_tax conjoint_mix conjoint_pork `x' ctX`x' cmX`x' cpX`x' `controls', cluster(id)
			regsave conjoint_tax conjoint_mix conjoint_pork `x' ctX`x' cmX`x' cpX`x' using subgroup_interactions_fig1.dta, ci pval  addlabel(figure, 1, interaction, `x', outcome, `y') append
			reg `y' conjoint_tax conjoint_mix conjoint_pork `x' ctX`x' cmX`x' cpX`x', cluster(id)	
			regsave conjoint_tax conjoint_mix conjoint_pork `x' ctX`x' cmX`x' cpX`x' using subgroup_interactions_fig1_nocontrols.dta, ci pval  addlabel(figure, 1, interaction, `x', outcome, `y') append
		}
	}

	foreach name in fig1 fig1_nocontrols {
	preserve
		clear
		*use "subgroup_interactions_`name'.dta"
		use "subgroup_interactions_fig1.dta"
		gen treat=0
		replace treat=1 if regexm(var, "ctX")
		replace treat=2 if regexm(var, "cmX")
		replace treat=3 if regexm(var, "cpX")
		keep if treat==1 | treat==2 | treat==3
		keep var coef stderr pval outcome treat
		replace outcome=outcome+"_tX" if treat==1
		replace outcome=outcome+"_mX" if treat==2
		replace outcome=outcome+"_pX" if treat==3
		replace var=subinstr(var,"cmX","",1)
		replace var=subinstr(var,"ctX","",1)
		replace var=subinstr(var,"cpX","",1)				
		replace coef = round(coef,.001)
		replace stderr = round(stderr,.001)
		replace pval = round(pval,.001)
		sort var
		gen order1=.
		replace order1=1 if outcome=="rep_chosen_tX"
		replace order1=2 if outcome=="rep_chosen_mX"
		replace order1=3 if outcome=="rep_chosen_pX"
		replace order1=4 if outcome=="cor_chosen_tX"
		replace order1=5 if outcome=="cor_chosen_mX"
		replace order1=6 if outcome=="cor_chosen_pX"

		sort var order1

		rename coef est_coef
		rename stderr est_stderr
		reshape long est_, i(var outcome order pval) j(type) string
		rename est_ estimate
		gen order2=.
		replace order2=1 if type=="coef"
		replace order2=2 if type=="stderr"
		sort var order1 order2
		drop outcome type treat
		order estimate, before(pval)
		reshape wide estimate pval, i(var order2) j(order1)
		

		rename estimate1 rep_chosen_tX
		rename estimate2 rep_chosen_mX
		rename estimate3 rep_chosen_pX
		rename estimate4 cor_chosen_tX
		rename estimate5 cor_chosen_mX
		rename estimate6 cor_chosen_pX

		
		foreach num of numlist 1/6 {
			replace pval`num'=. if order2==1
		}
		
		rename pval1 rep_chosen_tXp
		rename pval2 rep_chosen_mXp
		rename pval3 rep_chosen_pXp
		rename pval4 cor_chosen_tXp
		rename pval5 cor_chosen_mXp
		rename pval6 cor_chosen_pXp

		order order2, first
		
		gen order1=.
		replace order1=1 if var=="female"
		replace order1=2 if var=="republican"
		replace order1=3 if var=="independent"
		replace order1=5 if var=="ideology"
		replace order1=6 if var=="mayor"
		replace order1=7 if var=="commissioner"
		replace order1=9 if var=="served4"
		replace order1=10 if var=="close"
		replace order1=11 if var=="challenger"
		replace order1=12 if var=="unelected"
		replace order1=13 if var=="stayinoffice"
		replace order1=14 if var=="runforhigher"
		replace order1=15 if var=="atlarge"
		replace order1=16 if var=="multimember"
		replace order1=17 if var=="lesscollege"
		replace order1=18 if var=="bachelors"
		replace order1=19 if var=="gradschool"

		order order1, first
		sort order1 order2
		replace var="Female (1=yes)" if var=="female"
		replace var="Republican (1=yes)" if var=="republican"
		replace var="Independent (1=yes)" if var=="independent"
		replace var="Democrat (1=yes)" if var=="democrat"
		replace var="Self-Placed Ideology (7-pt., 1=Very Liberal)" if var=="ideology"
		replace var="Mayor (1=yes)" if var=="mayor"
		replace var="Commissioner (1=yes)" if var=="commissioner"
		replace var="Councilor (1=yes)" if var=="councilor"
		replace var="Has served 4 yrs. or less in elected office (1=yes)" if var=="served4"
		replace var="Won last election by less than 10% pts. (1=yes)" if var=="close"
		replace var="Faced challenger in primary or general (1=yes)" if var=="challenger"
		replace var="Unelected Official (1=yes)" if var=="unelected"
		replace var="Wants to hold munic. office in 5 yrs. (1=yes)" if var=="stayinoffice"
		replace var="Wants to hold higher office in 5 yrs. (1=yes)" if var=="runforhigher"
		replace var="Holds at-large seat (1=yes)" if var=="atlarge"
		replace var="In multi-member district (1=yes)" if var=="multimember"
		replace var="Has less than bachelor's degree (1=yes)" if var=="lesscollege"
		replace var="Has bachelor's degree (1=yes)" if var=="bachelors"
		replace var="Has graduate degree (1=yes)" if var=="gradschool"

		
		compress
		save "subgroup_interactions_`name'_clean.dta", replace
	restore
	}
